<?php
/**
 *   员工登录
*/

namespace app\admin\controller;

use app\facade\Basic;
use think\Exception;
use think\facade\Log;
use think\Request;
use \app\admin\service\Login as ServiceLogin;
class Login extends BaseController
{

    /**
     *  账号密码登录
     *  手机/邮箱登录
    */
    public function account(Request $request)
    {
        $param['account'] = $request->param('username',null);
        $param['password'] = $request->param('password',null);
        $param['verify'] = $request->param('verify','5555');
        $param['ip'] = $request->ip();
        /* 验证 */
//        $this->validateData($param,'Login.account');

        /* 登录操作 */
        $ServiceLogin = new ServiceLogin();
        $result = $ServiceLogin->account($param);


        return Basic::json($result);
    }


    /**
     *  退出系统
    */
    public function logout(Request $request)
    {
        $param['operator_id'] = $request->operator_id;
        $param['token'] = $request->token;
        $ServiceLogin = new ServiceLogin();
        $result = $ServiceLogin->logout($param);
        if($result){
            return Basic::json($result);
        } else {
            return Basic::json($result);
        }
    }
}
